package com.rdxer.repository;

import com.rdxer.model.Department;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface DepartmentRepository extends JpaRepository<Department,String>,JpaSpecificationExecutor<Department>{
    Department findByTitle(String title);

    @Query(value= "select * from department where id in (select department_id from department_role_account_relation\n" +
            "where  department_role_account_relation.account_id = ?\n" +
            "                                      group by department_id)",nativeQuery = true)
    List<Department> findAllByUid(String uid);
}
